﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using MaxStudio.Concrete.DBUtility;
using MaxStudio.Concrete.Server.Dao;
using MaxStudio.Concrete.Server.Interface;

namespace MaxStudio.Concrete.Server.Service
{
    public class RPTPhysicalPropertiesOfementTestService : ServiceHandle, IRPTPhysicalPropertiesOfementTest
    {
        #region IRPTPhysicalPropertiesOfementTest Members

        public OperationResult<List<tb_RPT_PhysicalPropertiesOfementTest>> GetAllPhysicalPropertiesOfementTest()
        {
            OperationResult<List<tb_RPT_PhysicalPropertiesOfementTest>> result = new OperationResult<List<tb_RPT_PhysicalPropertiesOfementTest>>();
            List<tb_RPT_PhysicalPropertiesOfementTest> list = new List<tb_RPT_PhysicalPropertiesOfementTest>();
            ConcreteDaoDataContext dataContext = getDateContext();
            try
            {
                list = dataContext.GetAllPhysicalPropertiesOfementTest();
                if (list == null)
                {
                    result.errorMessageKey = "Error";
                }
                else
                {
                    result.obj = list;
                    result.operationSuccess = true;
                }
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);

            }
            return result;
        }

        public OperationResult<List<tb_RPT_PhysicalPropertiesOfementTest>> GetPhysicalPropertiesOfementTestByContition(string strSamplingDate, string strTestDate, string strTestNumbers, string strCementManufacturer
                                                                                                                    , string strBatchNumber, string strStrengthGrade, string strTest
                                                                                                                    , string strCalculation, string strApproval)
        {
            OperationResult<List<tb_RPT_PhysicalPropertiesOfementTest>> result = new OperationResult<List<tb_RPT_PhysicalPropertiesOfementTest>>();
            List<tb_RPT_PhysicalPropertiesOfementTest> list = new List<tb_RPT_PhysicalPropertiesOfementTest>();
            ConcreteDaoDataContext dataContext = getDateContext();
            try
            {
                list = dataContext.GetPhysicalPropertiesOfementTestByContition(  strSamplingDate,   strTestDate,   strTestNumbers,   
                                                                                strCementManufacturer,   strBatchNumber,   strStrengthGrade,  
                                                                                strTest,   strCalculation,   strApproval);
                if (list == null)
                {
                    result.errorMessageKey = "Error";
                }
                else
                {
                    result.obj = list;
                    result.operationSuccess = true;
                }
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);

            }
            return result;
        }

        public OperationResult<tb_RPT_PhysicalPropertiesOfementTest> GetPhysicalPropertiesOfementTestById(int id)
        {
            ConcreteDaoDataContext dataContext = getDateContext();
            OperationResult<tb_RPT_PhysicalPropertiesOfementTest> result = new OperationResult<tb_RPT_PhysicalPropertiesOfementTest>();
            tb_RPT_PhysicalPropertiesOfementTest physicalPropertiesOfementTest;
            try
            {
                physicalPropertiesOfementTest = dataContext.GetPhysicalPropertiesOfementTestById(id);
                if (physicalPropertiesOfementTest == null)
                {
                    result.errorMessageKey = "Error";
                }
                else
                {
                    result.obj = physicalPropertiesOfementTest;
                    result.operationSuccess = true;
                }
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);

            }
            return result;
        }

        public OperationResult<tb_RPT_PhysicalPropertiesOfementTest> CreatePhysicalPropertiesOfementTest(tb_RPT_PhysicalPropertiesOfementTest entity)
        {
            OperationResult<tb_RPT_PhysicalPropertiesOfementTest> result = new OperationResult<tb_RPT_PhysicalPropertiesOfementTest>();
            ConcreteDaoDataContext dataContext = getDateContext();
            try
            {
                dataContext.CreatePhysicalPropertiesOfementTest(entity);
                dataContext.SubmitChanges();
                result.obj = entity;
                result.operationSuccess = true;
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);
            }

            return result;
        }

        public OperationResult<tb_RPT_PhysicalPropertiesOfementTest> ModifyPhysicalPropertiesOfementTest(tb_RPT_PhysicalPropertiesOfementTest entity)
        {
            OperationResult<tb_RPT_PhysicalPropertiesOfementTest> result = new OperationResult<tb_RPT_PhysicalPropertiesOfementTest>();
            ConcreteDaoDataContext dataContext = getDateContext();
            try
            {
                dataContext.ModifyPhysicalPropertiesOfementTest(entity);
                dataContext.SubmitChanges();
                result.obj = entity;
                result.operationSuccess = true;
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);
            }

            return result;
        }

        public OperationResult<tb_RPT_PhysicalPropertiesOfementTest> DeletePhysicalPropertiesOfementTest(tb_RPT_PhysicalPropertiesOfementTest entity)
        {
            OperationResult<tb_RPT_PhysicalPropertiesOfementTest> result = new OperationResult<tb_RPT_PhysicalPropertiesOfementTest>();
            ConcreteDaoDataContext dataContext = getDateContext();
            try
            {
                dataContext.DeletePhysicalPropertiesOfementTest(entity);
                dataContext.SubmitChanges();
                result.obj = entity;
                result.operationSuccess = true;
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);
            }

            return result;
        }

        #endregion
    }
}
